package com.hunray.rent.service.imp;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hunray.rent.dao.IUserDao;
import com.hunray.rent.entity.User;
import com.hunray.rent.security.PasswordHelper;
import com.hunray.rent.service.IUserService;

@Service
@Transactional
public class UserService extends BaseService<User> implements IUserService {

	private IUserDao dao;

	@Autowired
	public void setDao(IUserDao dao) {
		super.setDao(dao);
	}

	public User findByUsername(String username) {
		return dao.findByUsername(username);
	}
	@Transactional
	public User save(User user) {
		PasswordHelper.encryptPassword(user);
		return dao.save(user);
	}
}
